﻿using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Operations;
using Microsoft.VisualStudio.Utilities;

namespace Language.Intellisense.QuickInfo
{
    [Export( typeof( IQuickInfoSourceProvider ) )]
    [Name( "ToolTip QuickInfo Source" )]
    [Order( Before = "Default Quick Info Presenter" )]
    [ContentType( "redscript" )]
    internal class SourceProvider : IQuickInfoSourceProvider
    {
        #region Imports

        [Import]
        private ITextStructureNavigatorSelectorService NavigatorService { get; set; }

        [Import]
        private Stub.Database Database { get; set; }

        #endregion Imports

        #region IQuickInfoSourceProvider

        IQuickInfoSource IQuickInfoSourceProvider.TryCreateQuickInfoSource( ITextBuffer textBuffer )
        {
            ITextStructureNavigator navigator = NavigatorService.GetTextStructureNavigator( textBuffer );

            return new Source( textBuffer, navigator, Database );
        }

        #endregion IQuickInfoSourceProvider
    }
}
